
var zTreeObj;
$(function(){
    layui.use(['transfer', 'layer', 'util'], function() {
        var $ = layui.$
            , transfer = layui.transfer
            , layer = layui.layer
            , util = layui.util;
        var data = [];
        for(var key in roleAll){
            var d = {"value":roleAll[key].id,"title":roleAll[key].roleName};
            data.push(d);
        }
        var vals = [];
        for(var key in datas){
            vals.push(datas[key].roleId);
        }
        $("#roleids").val(vals.toString());
        //定义标题及数据源
        transfer.render({
            id:'role',
            elem: '#role'
            ,title: ['选择角色', '已选角色']  //自定义标题
            ,data: data
            ,value:vals.toString()
            //,width: 150 //定义宽度
            ,height: 210 //定义高度
            ,onchange: function(data, index){
                // console.log(data); //得到当前被穿梭的数据
                // console.log(index); //如果数据来自左边，index 为 0，否则为 1
                //获得右侧数据
                var roles = transfer.getData('role');
                var val = [];
                for(var key in roles){
                    val.push(roles[key].value);
                }
                $("#roleids").val(val.toString());
            }
        })
    })
})